﻿using Microsoft.AspNetCore.Mvc;


namespace MvcMovie1.Controllers
{
    public class LoginController : Controller
    {
        public IActionResult Index()
        {
            return View(); // 返回登录界面 
        }
  
    //登录验证
    //登录验证
    public IActionResult Check(string username, string pwd)
    {
        if (!String.IsNullOrEmpty(username) && username.Equals("wy") && !String.IsNullOrEmpty(pwd) && pwd.Equals("888"))
        {
            HttpContext.Session.SetString("username", username);
            return RedirectToAction("Index", "Test");
        }
        TempData["error"] = "用户名或密码错";
        return RedirectToAction("Index", "Login");
    }
        // 其他代码不变
        // 注销
        [Route("Logout")]
        public IActionResult Logout()
        {
            HttpContext.Session.Clear();
            return RedirectToAction("Index", "Home");
        }
    }
}

